﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PetriNetSharp.CustomUIControls
{
	/// <summary>
	/// Interaction logic for SharpToolTip.xaml
	/// </summary>
	public partial class SharpToolTip : UserControl
	{
		/// <summary>
		/// Identifies the Header Text dependency property
		/// </summary>
		public static readonly DependencyProperty HeaderProperty =
			DependencyProperty.Register("Header", typeof(string), typeof(SharpToolTip),
			new PropertyMetadata(""));

		/// <summary>
		/// Identifies the Text dependency property
		/// </summary>
		public static readonly DependencyProperty TextProperty =
			DependencyProperty.Register("TextProperty", typeof(string), typeof(SharpToolTip),
			new PropertyMetadata(""));



		/// <summary>
		/// Identifies the shortcut text property
		/// </summary>
		public static readonly DependencyProperty ShortcutTextProperty =
			DependencyProperty.Register("ShortcutText", typeof(string), 
			typeof(SharpToolTip));



		/// <summary>
		/// Createa a new sharp tool tip
		/// </summary>
		public SharpToolTip()
		{
			InitializeComponent();

			//Bind the dependencies to the properties of the ui elements
			Binding bind = new Binding();
			bind.Source = this;
			bind.Path = new PropertyPath(HeaderProperty);
			bind.Mode = BindingMode.TwoWay;
			bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
			headerLabel.SetBinding(Label.ContentProperty, bind);

			bind = new Binding();
			bind.Source = this;
			bind.Path = new PropertyPath(TextProperty);
			bind.Mode = BindingMode.TwoWay;
			bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
			textTextBlock.SetBinding(TextBlock.TextProperty, bind);

			bind = new Binding();
			bind.Source = this;
			bind.Path = new PropertyPath(ShortcutTextProperty);
			bind.Mode = BindingMode.TwoWay;
			bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
			shortcutLabel.SetBinding(Label.ContentProperty, bind);
		}

		/// <summary>
		/// Get or set the header 
		/// </summary>
		public string Header
		{
			get { return (string)GetValue(HeaderProperty); }
			set { SetValue(HeaderProperty, value); }
		}

		/// <summary>
		/// Get or set the text
		/// </summary>
		public string Text
		{
			get { return (string)GetValue(TextProperty); }
			set { SetValue(TextProperty, value); }
		}

		/// <summary>
		/// Get or set the Shortcut Text
		/// </summary>
		public string ShortcutText
		{
			get { return (string)GetValue(ShortcutTextProperty); }
			set { SetValue(ShortcutTextProperty, value); }
		}
	}
}
